require('stickUp')
import VueModal from './components/modal.vue'
import CartModal from './components/shoppingModal.vue'
import ImgZoom from './components/imgZoom.vue'
import CascadedSelector from './components/cascadedSelector.vue'
import InputNumber from './components/inputNumber.vue'
import Reserve from './components/reserve.vue'
import HomeCarousel from './components/homeCarousel.vue'
import Query from './query.js'

require('./app')({
  'vueModal': VueModal,
  'cartModal': CartModal,
  'cascadedSelector': CascadedSelector,
  'inputNumber': InputNumber,
  'reserve': Reserve,
  'homeCarousel': HomeCarousel,
}, function (vueInstance) {
    // $("#item-show-more").bind('click', function(){
    //   $('.inside-menu').toggle('slow')
    // })

    $(function() {
      // console.log($('.home-product-img').width())
      $('.home-product-img').height($('.home-product-img').width())

      Query.get('/floor')
        .then(res => {
          var parts = {}
          for (let index = 0; index < res.floors.length; index++) {
            parts[index] = 'home_floor_' + index
          }
          if ($('.stick_up').length > 0 && res.floors.length > 0) {
            $('.stick_up').stickUp({
              // parts: {
              //   0: 'home_floor_0',
              //   1: 'home_floor_1',
              //   2: 'home_floor_2',
              //   3: 'home_floor_3',
              //   4: 'home_floor_4',
              //   5: 'home_floor_5',
              //   6: 'home_floor_6'
              // },
              parts: parts, itemClass: 'menuItem', itemHover: 'active' })

            $('.stick_up').css('left', $('#home-container-div').offset().left - 70)
          }
        })
        .catch(error => {
        })

      // if($('.stick_up').length > 0 && floors){

      //   $('.stick_up').stickUp({
      //     parts: {
      //       0: 'home_floor_0',
      //       1: 'home_floor_1',
      //       2: 'home_floor_2',
      //       3: 'home_floor_3',
      //       4: 'home_floor_4',
      //       5: 'home_floor_5',
      //       6: 'home_floor_6'
      //     },
      //     itemClass: 'menuItem',
      //     itemHover: 'active'
      //   });

      //   $('.stick_up').css('left', $('#home-container-div').offset().left -70)
      // }
    })
     //let baiduEditor = require('./editor/editor.coffee')('editor-container')
      //if(baiduEditor) {
        //baiduEditor.doListen(function (umeditor) {
          //$('.edui-toolbar button').click(function() {
            //console.log(umeditor.getContent())
          //})
        //})
      //}
      $('#contact-mask').bind('click', function() {
        $('#contact-mask-panel').removeClass('hide')
      });
      $('#contact-mask-panel').bind('click', function() {
        $('#contact-mask-panel').addClass('hide')
      });

      let iframe = document.createElement('iframe')
      iframe.scrolling = 'no'

      let section=$('#mobile-ads-home')
      if(section.length > 0) {
        iframe.src = '/get_baidu_ads_for_mobile'
        $(iframe).css({
          'min-height' : "531px",
          'width' : '100%',
          'border' : 'none'
        })
        section.append(iframe);
      } else {
        iframe.src = '/get_baidu_ads'
        $(iframe).css({
          'min-height' : "310px",
          'width' : '100%',
          'border' : 'none'
        })
        $("#web-ads-home").append(iframe)
      }
})
